package com.ybfenpan.controller.admin.info;


import com.ybfenpan.controller.core.BaseController;
import com.ybfenpan.service.NoticeService;
import com.ybfenpan.taglib.pagetag.Pagination;
import com.ybfenpan.utils.MapUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


/**
 * Created by Administrator on 2016/3/25.
 */
@Controller

public class NoticeListController extends BaseController {
    @Resource
    private NoticeService noticeService;
   
   
    @RequestMapping("admin/info/noticeList.shtml")
    public String list(HttpServletRequest request) throws Exception{
        HashMap formMap = getParameterMap(request);
        
        formMap.put("top", 0);
        formMap.put("pagination.orderBy","commitDate desc");
        Pagination page = noticeService.queryForPageList("noticeForPage",formMap);
        request.setAttribute(Pagination.pageBeanName, page);
        return "admin/info/noticeList";
    }

    @RequestMapping("admin/info/noticeDelete.shtml")
    public String delete(HttpServletRequest request) throws Exception{
        Map formMap = getParameterMap(request);
        int id = MapUtil.getIntValue(formMap, "id");
        if(0 < id){
        	 
        	noticeService.delete(id);
        }
        return "redirect:noticeList.shtml";
       
    }
}
